import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    redirect: '/databoard/workbench'
  },

  {
    // 数据看版
    path: '/databoard',
    component: Layout,
    redirect: '/databoard/workbench',
    name: 'DataBoard',
    meta: { title: '数据看版', icon: 'line-computer' },
    children: [
      {
        // 工作台
        path: 'workbench',
        name: 'Workbench',
        component: () => import('@/views/data-board/workbench/index'),
        meta: { title: '工作台', icon: 'line-home', hideBreadcrumb: true }
      },
      {
        // 多种布局
        path: 'multiplelayout',
        name: 'MultipleLayout',
        component: () => import('@/views/data-board/multiple-layout/index'),
        meta: { title: '基础数据看板', icon: 'line-presentation', hideBreadcrumb: true }
      },
      {
        // 等分布局（等分数据看板）
        path: 'dividelayout',
        name: 'DivideLayout',
        component: () => import('@/views/data-board/divide-layout/index'),
        meta: { title: '等分数据看板', icon: 'line-presentation-alt', hideBreadcrumb: true }
      }
    ]
  },

  {
    // 表单页
    path: '/form',
    component: Layout,
    redirect: '/form/singleform',
    name: 'Form',
    meta: { title: '表单页', icon: 'line-align-justify' },
    children: [
      {
        // 单列表单
        path: 'singleform',
        name: 'SingleForm',
        component: () => import('@/views/form/single-form/index'),
        meta: { title: '单列表单', icon: 'line-border-vertical' }
      },
      {
        // 两列表单
        path: 'doubleform',
        name: 'DoubleForm',
        component: () => import('@/views/form/double-form/index'),
        meta: { title: '两列表单', icon: 'line-pause' }
      },
      {
        // 三列表单
        path: 'tripleform',
        name: 'TripleForm',
        component: () => import('@/views/form/triple-form/index'),
        meta: { title: '三列表单', icon: 'line-menu-vertical' }
      },
      {
        // 分组表单
        path: 'groupform',
        name: 'GroupForm',
        component: () => import('@/views/form/group-form/index'),
        meta: { title: '分组表单', icon: 'line-connect' }
      },
      {
        // 分步/分级表单
        path: 'stepform',
        name: 'StepForm',
        component: () => import('@/views/form/step-form/index'),
        meta: { title: '分步/分级表单', icon: 'line-list-numbered' }
      }
    ]
  },

  {
    // 列表页
    path: '/list',
    component: Layout,
    redirect: '/list/defaultlist',
    name: 'List',
    meta: { title: '列表页', icon: 'line-pages' },
    children: [
      {
        // 基础数据列表
        path: 'defaultlist',
        name: 'DefaultList',
        component: () => import('@/views/list/default-list/index'),
        meta: { title: '基础数据列表', icon: 'line-page' }
      },
      {
        // 高级筛选列表
        path: 'filtratelist',
        name: 'FiltrateList',
        component: () => import('@/views/list/filtrate-list/index'),
        meta: { title: '高级筛选列表', icon: 'line-page-content' }
      },
      {
        // 高级表格图表分析
        path: 'chartanalyze',
        name: 'ChartAnalyze',
        component: () => import('@/views/list/chart-analyze/index'),
        meta: { title: '高级表格图表分析', icon: 'line-calendar-alt' }
      },
      {
        // 高级表格图表列表
        path: 'chartlist',
        name: 'ChartList',
        component: () => import('@/views/list/chart-list/index'),
        meta: { title: '高级表格图表列表', icon: 'line-grid' }
      },
      {
        // 高级卡片列表
        path: 'cardlist',
        name: 'CardList',
        component: () => import('@/views/list/card-list/index'),
        meta: { title: '高级图片列表', icon: 'line-image' }
      },
      {
        // 卡片列表
        path: 'smallcardlist',
        name: 'SmallcardList',
        component: () => import('@/views/list/smallcard-list/index'),
        meta: { title: '卡片列表', icon: 'line-credit-card' }
      }
    ]
  },

  {
    // 详情页
    path: '/details',
    component: Layout,
    redirect: '/details/datafiltrate',
    name: 'Details',
    meta: { title: '详情页', icon: 'line-content' },
    children: [
      {
        // 基础信息详情页
        path: 'baseDetail',
        name: 'baseDetail',
        component: () => import('@/views/details/data-baseDetail/index'),
        meta: { title: '基础信息详情页', icon: 'line-memo' }
      },
      {
        // 紧凑信息详情页
        path: 'compactDetail',
        name: 'compactDetail',
        component: () => import('@/views/details/data-compactDetail/index'),
        meta: { title: '紧凑信息详情页', icon: 'line-notebook' }
      }
    ]
  },

  {
    // 结果页
    path: '/result',
    component: Layout,
    redirect: '/result/success',
    name: 'Result',
    meta: { title: '结果页', icon: 'line-smile' },
    children: [
      {
        // 成功页
        path: 'success',
        name: 'Success',
        component: () => import('@/views/result/success/index'),
        meta: { title: '成功页', icon: 'line-finished', text: '操作成功页' }
      },
      {
        // 失败页
        path: 'fail',
        name: 'Fail',
        component: () => import('@/views/result/fail/index'),
        meta: { title: '失败页', icon: 'line-close-circle' }
      }
    ]
  },

  {
    // 登录注册
    path: '/registration',
    component: Layout,
    redirect: '/registration/login',
    name: 'Registration',
    meta: { title: '登录注册', icon: 'line-at' },
    children: [
      {
        // 登陆
        path: 'login',
        name: 'Login',
        component: () => import('@/views/registration/login/index'),
        meta: { title: '登陆', icon: 'line-flag' }
      },
      {
        // 修改登陆密码
        path: 'changepassword',
        name: 'ChangePassword',
        component: () => import('@/views/registration/changepassword/index'),
        meta: { title: '修改登陆密码', icon: 'line-edit' }
      },
      {
        // 修改登陆邮箱
        path: 'changeemail',
        name: 'ChangeEmail',
        component: () => import('@/views/registration/changeemail/index'),
        meta: { title: '修改登陆邮箱', icon: 'line-mail' }
      },
      {
        // 重置密码-重置默认
        path: 'resetpasswords',
        name: 'ResetPasswords',
        component: () => import('@/views/registration/resetpasswords/index'),
        meta: { title: '重置密码-重置默认', icon: 'line-rotate' }
      }
    ]
  },

  {
    // 弹窗类
    path: '/modal',
    component: Layout,
    redirect: '/modal/groupmodal',
    name: 'Modal',
    meta: { title: '弹窗类', icon: 'line-swap-stroke' },
    children: [
      {
        // 分组表单弹框
        path: 'groupmodal',
        name: 'GroupModal',
        component: () => import('@/views/modal/groupModal'),
        meta: { title: '分组表单弹框', icon: 'line-layout-grid' }
      },
      {
        // 操作失败
        path: 'errormodal',
        name: 'ErrorModal',
        component: () => import('@/views/modal/errorModal'),
        meta: { title: '操作失败', icon: 'line-chose-square' }
      },
      {
        // 操作成功
        path: 'successmodal',
        name: 'SuccessModal',
        component: () => import('@/views/modal/successModal'),
        meta: { title: '操作成功', icon: 'line-check-square' }
      },
      {
        // 详细信息弹框
        path: 'infobasemodal',
        name: 'InfoBaseModal',
        component: () => import('@/views/modal/infoBaseModal'),
        meta: { title: '详细信息弹框', icon: 'line-keyboard-down' }
      },
      {
        // 表格式
        path: 'infotablemodal',
        name: 'InfoTableModal',
        component: () => import('@/views/modal/infoTableModal'),
        meta: { title: '表格式', icon: 'line-browser' }
      },
      {
        // 分步表单弹窗
        path: 'stepmodal',
        name: 'StepModal',
        component: () => import('@/views/modal/stepModal'),
        meta: { title: '分步表单弹窗', icon: 'line-left' }
      },
      {
        // 3列表单弹框
        path: 'threestepcolumnmodal',
        name: 'ThreeStepColumnModal',
        component: () => import('@/views/modal/threeColumnModal'),
        meta: { title: '3列表单弹框', icon: 'line-carousel' }
      },
      {
        // 2列表单弹框
        path: 'twostepcolumnmodal',
        name: 'TwoStepColumnModal',
        component: () => import('@/views/modal/twoColumnModal'),
        meta: { title: '2列表单弹框', icon: 'line-branches' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history',
  mode: 'hash',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

console.log(router)

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
